package br.com.carlosbarbero.springbatch.databasetoxml.tasklet;

import java.io.File;
import java.util.Properties;

import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.annotation.BeforeStep;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import br.com.carlosbarbero.springbatch.databasetoxml.service.EmpresaSaudeService;

@StepScope
public class EmpresaSaudeTasklet  implements Tasklet {
	
	private File arquivo = null;
	@Autowired
	@Qualifier("caminhoArquivoTemp")
	private Properties caminhoArquivoTemp;

	
	
	
	@Autowired
	private EmpresaSaudeService service;

	public RepeatStatus execute(StepContribution arg0, ChunkContext arg1)	throws Exception {
		arquivo =  new File(caminhoArquivoTemp.getProperty("file.path"));
		
		service.empresaSaudeServiceTeste();
		
		System.out.println("*********************"+arquivo.getAbsolutePath());
			
			//TODO remover arquivo do disco
		return RepeatStatus.FINISHED;
	}

}
